package com.qiyi.player.core.video.file.actors
{
   import flash.utils.ByteArray;
   import com.qiyi.player.core.video.file.actors.datatile.IFlvBlock;
   
   public class MediaUtils extends Object
   {
      
      public function MediaUtils() {
         super();
      }
      
      public static function isEqual(param1:ByteArray, param2:ByteArray) : Boolean {
         if(param1.length != param2.length)
         {
            return false;
         }
         param1.position = 0;
         param2.position = 0;
         var _loc3_:* = 0;
         var _loc4_:int = param1.length;
         while(_loc3_ < _loc4_)
         {
            if(param1.readByte() != param2.readByte())
            {
               return false;
            }
            _loc3_++;
         }
         return true;
      }
      
      public static function verifyFlvBlockHeaderConfigIsSame(param1:IFlvBlock, param2:IFlvBlock) : Boolean {
         if(Boolean(param1.configAudioTag) != Boolean(param2.configAudioTag))
         {
            return false;
         }
         if(Boolean(param1.configVideoTag) != Boolean(param2.configVideoTag))
         {
            return false;
         }
         var _loc3_:ByteArray = new ByteArray();
         var _loc4_:ByteArray = new ByteArray();
         if(param1.configAudioTag)
         {
            if(param1.configAudioTag.data.length != param2.configAudioTag.data.length)
            {
               return false;
            }
            param1.configAudioTag.write(_loc3_);
            param2.configAudioTag.write(_loc4_);
            if(!isEqual(_loc3_,_loc4_))
            {
               return false;
            }
         }
         if(param1.configVideoTag)
         {
            if(param1.configVideoTag.data.length != param2.configVideoTag.data.length)
            {
               return false;
            }
            _loc3_ = new ByteArray();
            _loc4_ = new ByteArray();
            param1.configVideoTag.write(_loc3_);
            param2.configVideoTag.write(_loc4_);
            if(!isEqual(_loc3_,_loc4_))
            {
               return false;
            }
         }
         return true;
      }
      
      public static function verifyFlvBlockContinuous(param1:IFlvBlock, param2:IFlvBlock) : Boolean {
         if(param1.segment == param2.segment)
         {
            return param1.endPosition - param2.startPosition >= 0;
         }
         if(param1.segment.index + 1 == param2.segment.index)
         {
            return param1.endPosition == param1.segment.totalBytes && param2.startPosition == 0;
         }
         return false;
      }
   }
}
